<template>
  <el-dialog title="审核" :visible.sync="visible" :close-on-click-modal="false" class="sign-add-or-update">
    <!-- 审核 -->
    <el-form :model="dataForm" ref="dataForm" label-width="auto" size="small">
      <el-form-item label="审核原因" prop="auditReason">
        <el-input v-model="dataForm.auditReason" maxlength="50" show-word-limit type="text" placeholder="审核原因"></el-input>
      </el-form-item>
    </el-form>

    <div slot="footer" class="dialog-footer">
      <div class="default-btn" @click="reject">驳回</div>
      <div class="default-btn primary-btn" @click="pass()">通过</div>
    </div>

  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      // 审核
      dataForm: {
        blockchainShopId: 0,
        auditReason: '',
      }
    }
  },

  methods: {
    init(id) {
      this.visible = true
      this.dataForm.blockchainShopId = id;
    },


    //驳回
    reject() {
      if (!this.dataForm.auditReason) {
        this.$message({
          type: 'error',
          message: '请输入驳回原因'
        });
        return
      } else {
        this.$http({
          url: this.$http.adornUrl('/platform/blockchainShop/auditShopChain'),
          method: 'post',
          data: this.$http.adornData({
            'blockchainShopId': this.dataForm.blockchainShopId,
            'blockchainShopStatus': -1,
            'auditReason': this.dataForm.auditReason
          })
        }).then(({ data }) => {
          this.$message({
            message: this.$i18n.t('sys.successful'),
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.visible = false
              this.$nextTick(() => {
                this.$emit('refreshDataList')
              })
            }
          })
        })
      }

    },
    /* 通过 */
    pass() {
      this.$http({
        url: this.$http.adornUrl('/platform/blockchainShop/auditShopChain'),
        method: 'post',
        data: this.$http.adornData({
          'blockchainShopId': this.dataForm.blockchainShopId,
          'blockchainShopStatus': 1,
          'auditReason': this.dataForm.auditReason
        })
      }).then(({ data }) => {
        this.$message({
          message: this.$i18n.t('sys.successful'),
          type: 'success',
          duration: 1500,
          onClose: () => {
            this.visible = false
            this.$nextTick(() => {
              this.$emit('refreshDataList')
            })
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.sign-add-or-update {
  &>>>.el-dialog__body {
    padding-top: 20px;
  }

  .main-container {
    padding: 0;
    margin-top: 0;

    &>>>.el-table__body-wrapper {
      max-height: 350px;
      overflow-y: auto;
    }

    &>>>.img-box {
      text-align: center;
    }

    .rotating-img {
      display: inline-block;
      width: 60px;
      height: 60px;
    }

    .rotating-img:not(:last-child) {
      margin-right: 5px;
    }

    .pla-tit,
    .cus-tit {
      margin-bottom: 10px;
      font-weight: bold;
      color: #333;
    }

    .cus-tit {
      margin-top: 25px;
    }
  }
}
</style>
